<template>
    <div>
        <h1>康复理疗</h1>
        <table class="table">
            <tbody>
                <tr>
                <td>自动生成</td>
                <td>
                    <input type="text" value="20250319589" readonly>
                </td>
            </tr>
            <tr>
                <td>康复名称</td>
                <td>
                    <input type="text" v-model="data.kangName">
                </td>
            </tr>
            <tr>
                <td>佣金</td>
                <td>
                    <input type="text" v-model="data.kangPrice">
                </td>
            </tr>
            <tr>
                <td>服务人数</td>
                <td>
                    <input type="text" v-model="data.kangNum">
                </td>
            </tr>
            <tr>
                <td>服务时长</td>
                <td>
                    <input type="text" v-model="data.kangDate">
                </td>
            </tr>
            <tr>
                <td><span style="color: red;">*</span>状态</td>
                <td>
                    <input type="radio" name="data.kangStart" :value="true" v-model="data.kangStart">启用
                    <input type="radio" name="data.kangStart"  :value="false" v-model="data.kangStart">禁用
                </td>
            </tr>
            <tr>
                    <td>
                        <input type="button" value="添加" @click="Add" >
                        
                    </td>
                </tr>
            </tbody>
            
        </table>
    </div>
</template>

<script setup lang="ts">
import {onMounted, ref} from 'vue';
import axios from 'axios';
import moment from 'moment';
const router=moment();
onMounted(()=>{
    zi();
})
const data=ref({
    "kangId": 0,
    "code": "",
    "kangName": "",
    "kangPrice": "",
    "kangNum": 0,
    "kangDate": 0,
    "kangStart": true,
    "Img":"",
    "deleId": 0
    
})
const Add=()=>{
    if(data.value.kangName=="")
{
    alert("康复名称不能为空");
    return;
}
if(data.value.kangPrice=="")
{
    alert("佣金不能为空！");
    return;
}
if(data.value.kangNum==0)
{
    alert("服务人数不能为空！");
    return;
}
if(data.value.kangDate==0)
{
    alert("服务时长不能为空！");
    return;
}
    axios.post("https://localhost:7235/api/KangFu/Add",data.value).then(res=>{
        if(res.data>0)
    {
        alert("添加成功！");
        location.href="Showfu"
    }
    else{
        alert("添加失败！");
    }
    })
}
const zi=()=>{
    var c=moment().format("YYYYMMdd");
    var d=999;
}
</script>

<style scoped>

</style>